package com.platform.system.enums;

import lombok.Getter;

/**
 * @author Huangkai
 */

@Getter
public enum TopicEnums {

    DEVICE_UPGRADE(0,"device/upgrade", "升级任务通知"),

    DEVICE_INFO(1, "device/info", "下发设备信息");

    /**
     * 状态码
     * */
    public Integer code;


    /**
     * 主题
     */
    public String topic;

    /**
     * 提示信息
     * */
    public String desc;

    /**
     * @param code 状态码
     * @param topic
     * @param desc
     * */
    TopicEnums(Integer code, String topic, String desc) {
        this.code = code;
        this.topic = topic;
        this.desc = desc;
    }

    public static TopicEnums findEnumByCode(Integer code) {
        for (TopicEnums topicEnum : TopicEnums.values()) {
            if (topicEnum.getCode().equals(code)) {
                //如果需要直接返回name则更改返回类型为String,return statusEnum.name;
                return topicEnum;
            }
        }
        throw new IllegalArgumentException("code is invalid");
    }
}
